package com.ymdd.library.permission;

import android.content.Intent;
import android.net.Uri;
import android.provider.Settings;
import com.ymdd.library.permission.target.Target;

/**
 * Created by 000286 on 2017/9/22.
 * Description
 */

public class SettingExecutor implements SettingService {

  private Target mTarget;
  private int mRequestCode;

  public SettingExecutor(Target mTarget, int mRequestCode) {
    this.mTarget = mTarget;
    this.mRequestCode = mRequestCode;
  }

  @Override public void cancel() {

  }

  @Override public void execute() {
    Intent mIntent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
    Uri uri = Uri.fromParts("package", mTarget.getContext().getPackageName(), null);
    mIntent.setData(uri);
    mTarget.startActivityForResult(mIntent, mRequestCode);
  }
}
